package com.yuanian.timingwheel.threadpool;

import java.util.concurrent.*;

public class ThreadPoolExecutorFactory {

    public static LinkedBlockingQueue queue = new LinkedBlockingQueue<>(5000);

    private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,
            Runtime.getRuntime().availableProcessors() + 1,
            1000,
            TimeUnit.SECONDS,
            queue,

            new RejectedExecutionHandler() {
                @Override
                public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
                    System.out.println("-------RejectedExecutionHandler:" + r);
                    r.run();
                }
            }
    );

    public static ThreadPoolExecutor getThreadPool(){

        // 创建线程池
        return threadPoolExecutor;

    }
}
